from collections import defaultdict

from common.mssql_helper import g_msql_inst

__author__ = "Ypf"
_date_ = "2019/8/29-16:42"

def name_copy(name):
    list1 = []
    for i in range(12):
        list1.append(name)
    value_tuple = tuple(list1)
    return value_tuple

class CpbFy(object):
    @staticmethod
    def get_jd_dic(sql,name):
        end_sql=sql%name_copy(name)
        res_list1 = g_msql_inst.fetch_all(end_sql)
        dic = defaultdict(dict)
        for (Q1,Q2,Q3,Q4) in res_list1:
            dic[name] = [Q1,Q2,Q3,Q4]
        return  dic
    @staticmethod
    def get_jdch_dic(sql,name,years):
        years='%'+str(years)+'%'
        end_sql=sql%(name,years)
        print(end_sql)
        res_list1 = g_msql_inst.fetch_all(end_sql)

        dic = defaultdict(dict)
        for (Q1,Q2,Q3,Q4) in res_list1:
            dic[name] = [Q1,Q2,Q3,Q4]
        return  dic